#include <iostream>
#include <string>
#include <bitset>

using namespace std;

// 1290. 二进制链表转整数
// https://leetcode.cn/problems/convert-binary-number-in-a-linked-list-to-integer/description/?envType=daily-question&envId=2025-07-14



 struct ListNode {
     int val;
     ListNode *next;
     ListNode() : val(0), next(nullptr) {}
     ListNode(int x) : val(x), next(nullptr) {}
     ListNode(int x, ListNode *next) : val(x), next(next) {}
 };

class Solution {
public:
    int getDecimalValue(ListNode* head) {
        string binaryNum;
        while(head != nullptr){
            binaryNum.push_back(head->val + '0');
            head = head->next;
        }
        bitset<32> ret{binaryNum};
        return ret.to_ulong();
    }
};

int main()
{
    return 0;
}